<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    @Author 硕鼠
    @Date 2020/4/17 17:10
    @Version 1.0
    @Description 文件说明
  -->
    <meta charset="UTF-8">
    <title>原型</title>
    <script>
        var arr1 = new Array(12,13,14);
        var arr2 = new Array(12,13,14);

        Array.prototype.sum = function(){    //class
        // arr1.sum = function () {         //行间样式
            var result = 0;
            for (var i = 0;i < this.length;i ++){
                result += this[i];
            }
            return result;
        }
        alert(arr1.sum());
        alert(arr2.sum());
    </script>

</head>
<body>

</body>
</html>